let db = require('./db');
const handle210 = function (api) {
    if (api !== 210) return;
    return JSON.stringify({
        code: 200,
        message: '操作成功',
        data: {
            "cwkc": 200,
            "cwkk": 233,
            "cwkg": 322
        }
    })
};
const handle211 = function (api) {
    if (api !== 211) return;
    return JSON.stringify({
        code: 200,
        message: '操作成功',
        data: {
            "cwkcLimit": [80, 120],
            "cwkkLimit": [200, 300],
            "cwkgLimit": [300, 400]
        }
    })
};
const handle220 = function (api) {
    if (api !== 220) return;
    return JSON.stringify({
        code: 200,
        message: '操作成功',
        data: {
            "clzl": parseFloat((800 + Math.random() * 10).toFixed(1))
        }
    })
};
const handle221 = function (api) {
    if (api !== 221) return;
    return JSON.stringify({
        code: 200,
        message: '操作成功',
        data: {
            "limitLo": 2000,
            "limitHi": 3000,
            "qyczbzl": 1500 + Number((Math.random() * 100).toFixed(0))

        }
    })
};

const handle404 = function (api,req,res) {
    if (api !== 404) return;
    db.query(req.body.data.sql, function (err, recordset) {
        if (err) {
            res.send(JSON.stringify({code: 500, message: err.message}));
            return;
        }
        res.send(JSON.stringify({code: 200, message: '查询成功', data: recordset.recordset}))
        return;
    });
    return true;
    return JSON.stringify({
        code: 200,
        data: [
            {
                jylsh: '44512221020800001',
                jycs: '1',
                hphm: '粤B123456',
                kssj: '2021-02-25 13:23:42',
                jyjgbh: '4403000008'
            },
            {jylsh: 'MYT20210223094153', jycs: '1', hphm: '粤AZSG12', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093017', jycs: '1', hphm: '粤A', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093628', jycs: '1', hphm: '粤AWQEQW1', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224093720', jycs: '1', hphm: '粤B2345', kssj: null, jyjgbh: '4403000008'},
            {jylsh: 'MYT20210224094649', jycs: '1', hphm: '皖AQWQ123', kssj: null, jyjgbh: '4403000008'}
        ]
    });
}
const handle = {
    handle210,
    handle211,
    handle220,
    handle221,
    handle404
}
module.exports = handle;